package com.sailfish.springbootdemo.dao.db1;

import com.sailfish.springbootdemo.common.DB1TableName;
import com.sailfish.springbootdemo.pojo.db1.LineBaseParam;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface LineBaseParamDao {

    /**
     * 根据类型查询 所有参数
     * @param searchValue
     * @param lineBaseBigTypeId
     * @param lineBaseSmallTypeId
     * @return
     */
    /*@Results(id = "lineBaseParamResultMap", value = {
            @Result(column = "line_base_param_id", property = "lineBaseParamId", jdbcType = JdbcType.INTEGER),
            @Result(column = "line_base_param_key", property = "lineBaseParamKey", jdbcType = JdbcType.VARCHAR),
            @Result(column = "line_base_param_name", property = "lineBaseParamName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "line_base_param_value", property = "lineBaseParamValue", jdbcType = JdbcType.VARCHAR),
            @Result(column = "line_base_big_type_id", property = "lineBaseBigTypeId", jdbcType = JdbcType.INTEGER),
            @Result(column = "line_base_small_type_id", property = "lineBaseSmallTypeId", jdbcType = JdbcType.INTEGER),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "sort", property = "sort", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.DATETIMEOFFSET),
    })
    @Select("<script>" +
            "select * from " + DB1TableName.LINE_BASE_PARAM + " where 1 = 1 " +
            "<if test='searchValue != null and searchValue != \"\" '>" +
            " and line_base_param_name like CONCAT('%',#{searchValue},'%')" +
            "</if>" +
            "<if test='lineBaseBigTypeId != null and lineBaseBigTypeId != \"\" '>" +
            " and line_base_big_type_id = #{lineBaseBigTypeId}" +
            "</if>" +
            "<if test='lineBaseSmallTypeId != null and lineBaseSmallTypeId != \"\" '>" +
            " and line_base_small_type_id = #{lineBaseSmallTypeId}" +
            "</if>" +
            " order by sort" +
            "</script>")
    List<LineBaseParam> getAllLineBaseParamByType(@Param("searchValue")String searchValue, @Param("lineBaseBigTypeId") Integer lineBaseBigTypeId, @Param("lineBaseSmallTypeId") Integer lineBaseSmallTypeId);


    @Select("select * from " + DB1TableName.LINE_BASE_PARAM + " where line_base_param_key = #{lineBaseParamKey}")
    @ResultMap(value = "lineBaseParamResultMap")
    LineBaseParam getLineBaseParamByKey(@Param("lineBaseParamKey") String lineBaseParamKey);*/
}
